package com.fast.controller.thread.task;

import cn.hutool.core.lang.Assert;
import cn.hutool.core.thread.ThreadUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * 记账生成凭证
 *
 * @author hjw
 * @since 2021年12月07日 14:35:00
 */
@Component
@Slf4j
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class TestTask implements Runnable {

	private Long businessId;

	public void setBusinessId(Long businessId) {
		this.businessId = businessId;
	}

	@Override
	public void run() {
		log.info("线程:【{}】执行的businessId为:{}", Thread.currentThread().getName(), businessId);
		Assert.isTrue(ThreadUtil.sleep(5000));
		System.out.println("调用要执行的任务方法");
		businessId++;
	}
}
